<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="/struts-tags" prefix="s" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>    
    <title>商品列表</title>
    <c:set var="path" value="${pageContext.request.contextPath }"/>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
  	<link rel="stylesheet" href="${path}/css/ros_right.css" type="text/css"></link>
  	<script language="javascript" src="${path}/js/table.js"></script>
  	<script type="text/javascript">
  		function showDialogForEdit(id){
			window.showModalDialog('ProductAction!updateProductDialog?product.productId='+id,'','dialogWidth=450px;dialogHeight=350px;');
		}  	
		
		function showDialogForView(id){
			window.showModalDialog('ProductAction!updateProductDialog?product.productId='+id,'','dialogWidth=450px;dialogHeight=350px;');
		} 
		
		function showDialogForAdd(){
			window.showModalDialog('ProductAction!addUI','','dialogWidth=450px;dialogHeight=350px;');
		}  
		
  	</script>
  	
  	</head>
  
  <body>
	<div class="formtable_title">
	<span class="icons iconsh">&nbsp;</span><strong class="title">查询条件</strong>
	</div>
	<s:form action="ProductAction!productList">
	<table border="0" cellspacing="0" cellpadding="0" class="formtable">  
	  <tr>
	    <td align="right" class="formtable_td01">商品编码：</td>
	    <td class="formtable_td02"><input type="text" name="product.productCode" id="product.productCode" class="input" /></td>
	    <td align="right" class="formtable_td01">商品名称：</td>
	    <td class="formtable_td02"><input  type="text"  name="product.productName" id="product.productName"  class="input" /></td>
	  </tr> 
	</table>
	<div class="buttondiv">
 	  <input  class="button" type="submit" name="btnProductAdd" id="btnProductAdd" value="商品新增" onclick="showDialogForAdd()"/> 
 	  <input  class="button" type="submit" name="btnSearch" id="btnSearch" value="查 询" />
	</div>
  	</s:form>
	<div class="listtable_title">
	<span class="icons iconsh">&nbsp;</span><strong class="title">商品列表</strong>
	</div>
	<table border="0" cellspacing="0" cellpadding="0" class="listtable">	
			<tr>
				<th align="center" nowrap="nowrap">序号</th>				
				<th>商品编码</th>
				<th>商品名称</th>
				<th>成本价格</th>
				<th>销售价格</th>
				<th>操作</th>
			</tr>	
		<c:forEach items="${ products }" var="product"  varStatus="status" >
			<tr>
				<td align="center" nowrap="nowrap">${ status.index + 1}</td>
				<td align="center">${product.productCode }</td>
				<td align="center">${product.productName }</td>
				<td align="center">${product.costPrice }</td>
				<td align="center">${product.salesPrice }</td>
				<td align="center">
					<img src="${path }/images/page_white_edit.png" alt="修改" onclick="showDialogForEdit(${product.productId})"/>
					<img src="${path }/images/page_white_text.png" alt="查看" onclick="showDialogForView(${product.productId})"/>
					<a href="ProductAction!deleteProduct?product.productId=${product.productId }">
						<img src="${path }/images/cross.png" alt="删除"/>
					</a>
				</td>
			</tr>	
		</c:forEach>
			<tr>
				<td height="30" colspan="6">
					<table width="100%" border="0" cellspacing="0" cellpadding="0">
						<tr>
							<td width="33%">
								<div align="left">
									<span class="STYLE22">&nbsp;共有<strong>
											${page.totalCount }</strong> 条记录，当前第<strong>
											${page.currentPage }</strong> 页，共 <strong>${page.totalPage }</strong>
										页</span>
								</div>
							</td>
							<td width="67%" align="right">
								<table width="312" border="0" align="right" cellpadding="0"
									cellspacing="0">
									<tr>
										<s:if test="true==page.hasPrePage">
											<td width="49" class="STYLE22">
												<div align="center">
													<a href="javascript:gotoPage('0')">首页</a>
												</div>
											</td>
											<td width="49" class="STYLE22">
												<div align="center">
													<a href="javascript:gotoPage('${page.currentPage -1}')">上一页</a>
												</div>
											</td>
										</s:if>
										<s:else>
											<td width="49" class="STYLE22">
												<div align="center">
													<span title="首页">首页</span>
												</div>
											</td>
											<td width="49" class="STYLE22">
												<div align="center">
													<span title="上一页">上一页</span>
												</div>
											</td>
										</s:else>
										<s:if test="true==page.hasNextPage">
											<td width="49" class="STYLE22">
												<div align="center">
													<a href="javascript:gotoPage('${page.currentPage +1}')">下一页</a>
												</div>
											</td>
											<td width="49" class="STYLE22">
												<div align="center">
													<a href="javascript:gotoPage('${page.totalPage}')">尾页</a>
												</div>
											</td>
										</s:if>
										<s:else>
											<td width="49" class="STYLE22">
												<div align="center">
													<span title="下一页">下一页</span>
												</div>
											</td>
											<td width="49" class="STYLE22">
												<div align="center">
													<span title="尾页">尾页</span>
												</div>
											</td>
										</s:else>
										<td width="37" class="STYLE22">
											<div align="center">
												转到
											</div>
										</td>
										<td width="30" class="STYLE22">
											<div align="center">
												<input type="text" name="textfield" id="textfield"
													style="width: 20px; height: 18px; font-size: 12px; border: solid 1px #7aaebd;" />
											</div>
										</td>
										<td width="22" class="STYLE22">
											<div align="center">
												页
											</div>
										</td>
										<td width="35">
											<input type="button"
												style="background: url(images/go.gif); height: 15px; width: 37px; border: none;"
												onclick="javascript:goPage();" value="GO"/>
											<script type="text/javascript">
												function goPage(){
													var countPage=${page.totalPage};
													var pagesValue=document.getElementById("textfield").value;
													if(validateNum(pagesValue)){
														if(pagesValue>0){
															if(pagesValue>countPage){
																alert("超出的总页数，请重新输入！");
																return false;
															}else{
																gotoPage(pagesValue);
															}
														}else{
															alert('请输入大于零的数字！');
															return false;
														}
													}
												}
												function gotoPage(pageNum){
													document.forms[0].action="<%=request.getContextPath()%>//basicinfo/ProductAction!productList?currentPage="+pageNum;
													document.forms[0].onsubmit="true";
													document.forms[0].submit();
												}
												function validateNum(pageNum_){
													var strTemp  = "0123456789";                      	
												    if (pageNum_.length > 0){                                         	
													   	 for (var i = 0; i < pageNum_.length; i++) {  	    
												        	var j = strTemp.indexOf(pageNum_.charAt(i));    
												        	if (j == -1) {                              
												               alert("请输入正整数!");          		
												               return false;                     		
												        	}                                    		
													   	 }                                  		
												    } 
												    return true; 
												}
											</script>
										</td>
									</tr>
								</table>
							</td>
						</tr>
					</table>
				</td>
			</tr>
	</table>
	<!-- 
	<div class="pagein fr"> <span class="text">检索到 <strong>16</strong> 条记录</span><span class="disabled">首页</span><a class="prev" href="#">上一页</a><span class="current">1</span><a href="#?page=2">2</a><a href="#?page=3">3</a><a href="#?page=4">4</a><a href="#?page=5">5</a><a class="next" href="#?page=2">下一页</a><a class="next" href="#">末页</a></div>
  	 -->
  </body>
</html>
